#include<iostream>
#include<vector>
#include<sys/types.h>
#include<unistd.h>

#define PNUM 5

using namespace std;

//描述管道的类
class channel
{
public:

    channel(int Wfd, pid_t processPID, string processName)
        :_Wfd(Wfd), _processPID(processPID), _processName(processName)
    {}
private:
    int _Wfd;
    pid_t _processPID;
    string _processName;
};

int main()
{
    //组织
    vector<channel> PPool;

    //1.构建父进程和各个子进程之间的管道 
    for(int i = 0; i < PNUM; i++)
    {
        int pidfd[2];
        pipe(pidfd);

        pid_t pid = fork();
        if(pid > 0)
        {
            //父进程要写，关闭读
            close(pidfd[0]);
            string name("child");
            name += to_string(pid);
            channel ch(pidfd[1], pid, name);
            PPool.push_back(ch);
        }
        else
        {
            //子进程要读，关闭写
            close(pidfd[1]);
            exit(0);
        }
    }

    //2.进程控制


}